package com.aoxon.cargo.component;

import java.util.List;

import android.app.Activity;
import android.widget.BaseAdapter;
import android.widget.GridView;

import com.aoxon.cargo.R;
import com.aoxon.cargo.view.MyGridView;
import com.aoxon.cargo.view.MyScrollView;

/**
 * 供应端物品瀑布流的数据加载显示
 * 
 * @author ZZJ
 * 
 */
public class WaterFallShowStore implements MyScrollView.OnScrollListener {

	private MyGridView myGridView;
	private MyScrollView myScrollView;

	private BaseAdapter adapter;

	private List<?> list;

	public WaterFallShowStore(Activity activity, BaseAdapter adapter,
			List<?> list) {

		myScrollView = (MyScrollView) activity
				.findViewById(R.id.msvPurGridShowStore);
		myGridView = (MyGridView) activity
				.findViewById(R.id.mgvPurGridShowStore);

		this.adapter = adapter;
		this.list = list;

		myScrollView.getView();
		myScrollView.setOnScrollListener(this);

		myGridView.setNumColumns(3);
		myGridView.setAdapter(adapter);
		adapter.notifyDataSetChanged();
	}

	
	public void setListFlag(int flag){
		myScrollView.setVisibility(flag);
	}
	
	
	/**
	 * 设置显示的列数
	 * 
	 * @param num
	 */
	public void setNumColumns(int num) {
		myGridView.setNumColumns(num);
	}

	/**
	 * 获取当前的GridView
	 * 
	 * @return
	 */
	public GridView getGridView() {
		return myGridView;
	}

	/**
	 * 清空所有列中的子项显示和列表数据
	 */
	public void clearView() {
		list.clear();
		adapter.notifyDataSetChanged();

	}

	/**
	 * 设置当前列表数据
	 * 
	 * @param list
	 */
	public void setList(List<?> list) {
		this.list = list;
	}

	@Override
	public void onBottom() {
		// TODO Auto-generated method stub
	}

	@Override
	public void onTop() {
		// TODO Auto-generated method stub
	}

	@Override
	public void onScroll() {
		// TODO Auto-generated method stub
	}
	
	// 即将到达底部（2/3处）
	@Override
	public void onWillToBottom() {
		
	}

	public interface ToLoad {
		public boolean doLoad() throws Exception;
	}

	public interface Command {
		public void doCommand();
	}


}
